#ifndef NET_CALLBACK_H_
#define NET_CALLBACK_H_
#include <fermat/net/iobuffer.h>
#include <fermat/common/timestamp.h>
#include <fermat/common/buffer_slice.h>
#include <functional>
#include <memory>

using fermat::Timestamp;
using fermat::PageBufferSliceQueuePtr;
namespace fermat {
namespace net{

class TcpConnection;
typedef std::shared_ptr<TcpConnection> TcpConnectionPtr;
typedef std::function<void (const TcpConnectionPtr&)> ConnectionCallback;
typedef std::function<void (const TcpConnectionPtr&)> CloseCallback;
typedef std::function<void (const TcpConnectionPtr&)> WriteCompleteCallback;
typedef std::function<void (const TcpConnectionPtr&, size_t)> HighWaterMarkCallback;

// the data has been read to (buf, len)
typedef std::function<void (const TcpConnectionPtr&,
                              PageBufferSliceQueuePtr,
                              Timestamp)> MessageCallback;

void defaultConnectionCallback(const TcpConnectionPtr& conn);
void defaultMessageCallback(const TcpConnectionPtr& conn,
                            PageBufferSliceQueuePtr buffer,
                            Timestamp receiveTime);

}
}

#endif
